package com.xw.dao;

import com.xw.entity.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description: ${DESCRIPTION}
 * @Author: ASUS
 * @Date: 2024/12/19 9:17
 * @Version: 1.0
 */

@Mapper
public interface MessageDao {

    @Insert("INSERT INTO message (send_type, user_id, content, create_time) " +
            "VALUES (#{sendType}, #{userId}, #{content}, NOW())")
    int insertMessage(Message message);

    @Select("SELECT * FROM message WHERE user_id = #{userId}")
    List<Message> selectMessagesByUserId(@Param("userId") String userId);

    // 可以根据需要添加更多的方法，例如根据消息ID查询、更新消息、删除消息等
}